<template>
  <view class="content">
    <view class="components-title">
      <view class="components-title-t">gg-switch</view>
      <view class="components-title-d">滑块开关</view>
    </view>
    <gg-nav-group label="Boolean类型；返回或默认值只能为：true或false">
      <gg-switch label="是否为true" v-model="switch1" :tip="tip" labelWidth="80" />
    </gg-nav-group>
    <gg-nav-group label="Number类型；返回或默认值只能为：0或1">
      <gg-switch label="是否为1" v-model="switch2" :tip="tip" />
    </gg-nav-group>
    <gg-nav-group label="String类型；返回或默认值只能为：'0'或'1'">
      <gg-switch label="是否为'1'" v-model="switch3" :tip="tip" />
    </gg-nav-group>
  </view>
</template>

<script>
export default {
  data() {
    return {
      switch1: false,
      switch2: 0,
      switch3: '0',
      tip: '这是一个滑块开关组件'
    };
  },
  onLoad() {
    setTimeout(() => {
      this.testReqMocck().then((res) => {
        this.switch1 = true
        this.switch2 = 1
        this.switch3 = '1'
      });
    }, 1000)

  },
  methods: {
    testReqMocck(testData) {
      return new Promise((resolve, reject) => {
        resolve({
        });
      });
    }
  }
}
</script>

<style>
page {
  background: #f1f1f1;
}
</style>
